<extend name="Public:common"/>
<block name="css">
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css"  media="all">
    <style>
        .newMess th{text-align:center;}
        th,td{padding: 10px;}
    </style>
</block>
<block name="content">
    <div class="page-header"><h1><i class="fa fa-home"></i> 首页>商家管理>景区供应商>景点审核</h1></div>
    <div class="container-fluid">
        <form action="" method="post">
            <input type="hidden" value="{:I('supplier_id')}" name="supplier_id">
            <input type="hidden" value="{:I('scenic_priceId')}" name="scenic_priceId">
            <input type="hidden" value="{$scenicInfo.scenic_id}" name="scenic_id">
            <table class="table table-striped table-bordered table-hover table-condensed text-center">
                <tbody>
                <tr>
                    <td style="width:25%;"><b> <span class="required">*</span>景点名称</b></td>
                    <td class="text-left">
                         <input type="text" name="scenic_name" value="{$scenicInfo['scenic_name']}" placeholder="请输入景点名称" required>
                    </td>
                </tr>
                <tr>
                    <td style="width:25%;"><b> <span class="required">*</span>景点等级</b></td>
                    <td class="text-left" id="seatList">
                        <select name="scenic_level" id="scenic_level">
                            <option value="1"  <if condition="$scenicInfo['scenic_level'] eq 1">selected</if>>1A级景区</option>
                            <option value="2" <if condition="$scenicInfo['scenic_level'] eq 2">selected</if>>2A级景区</option>
                            <option value="3" <if condition="$scenicInfo['scenic_level'] eq 3">selected</if>>3A级景区</option>
                            <option value="4" <if condition="$scenicInfo['scenic_level'] eq 4">selected</if>>4A级景区</option>
                            <option value="5" <if condition="$scenicInfo['scenic_level'] eq 5">selected</if>>5A级景区</option>
                        </select>
                    </td>
                </tr>

               <!-- <tr>
                    <td style="width:25%;"><b> <span class="required">*</span>所在地</b></td>
                    <td class="text-left">

                        国家
                        <select name="start_country" id="ar_country_id"  onchange="getProvince(this,'ar')" required>
                            <option value="">==选择国家==</option>
                            <volist name="country" id="vo">
                                <option  <if condition="$scenicInfo['country'] eq $vo['areaId']">selected</if> value="{$vo.areaId}">{$vo.areaName}</option>
                            </volist>
                        </select>
                        省
                        <select name="start_province" id="ar_province_id"  onchange="getCity(this,'ar')" required>
                            <option value="">==选择省==</option>
                            <volist name="cityList['province_list']" id="vo">
                                <option <if condition="$scenicInfo['province'] eq $vo['areaId']">selected</if>  value="{$vo.areaId}">{$vo.areaName}</option>
                            </volist>
                        </select>
                        市
                        <select name="start_city" id="ar_city_id"  onchange="getArea(this,'ar')" required>
                            <option value="">==选择市==</option>
                            <volist name="cityList['city_list']" id="vo">
                                <option <if condition="$scenicInfo['city'] eq $vo['areaId']">selected</if> value="{$vo.areaId}">{$vo.areaName}</option>
                            </volist>
                        </select>
                        区
                        <select name="start_area"   id="ar_area_id"  required>
                            <option value="">==选择区==</option>
                            <volist name="cityList['area_list']" id="vo">
                                <option <if condition="$scenicInfo['area'] eq $vo['areaId']">selected</if>  value="{$vo.areaId}">{$vo.areaName}</option>
                            </volist>
                        </select>

                    </td>
                </tr>-->



                <tr>
                    <td colspan="2" style="width:25%;">
                        <p>
                            <b> <span class="required">*</span>价格信息</b>
                        </p>

                        <table class="table table-striped table-bordered table-hover table-condensed text-center" id="addTr">
                            <tbody>
                            <tr>
                                <td rowspan="2" style="width:15%">币种</td>
                                <td colspan="2" style="width:15%">外币成本</td>
                                <td  style="width:15%">汇率</td>
                                <td colspan="2" style="width:15%">人民币成本</td>
                                <td rowspan="2" style="width:15%">座椅数量</td>
                            </tr>
                            <tr>
                                <td>儿童价</td>
                                <td>成人价</td>
                                <td>汇率</td>
                                <td>儿童价</td>
                                <td>成人价</td>
                            </tr>
                             <tr id="tr_">
                                 <td>
                                     <input class="form-control"  type="text" name="room[id][money_type]" value="{$scenicInfo.money_type}" required>
                                 </td>
                                 <td>
                                     <input class="form-control related"  type="text" name="room[id][child_foreign_cost]" value="{$scenicInfo.child_foreign_cost}">
                                 </td>
                                 <td>
                                     <input class="form-control related"  type="text" name="room[id][adult_foreign_cost]" value="{$scenicInfo.adult_foreign_cost}">
                                 </td>
                                 <td>
                                     <input class="form-control exchange_rate"  type="text" name="room[id][exchange_rate]" value="{$scenicInfo.exchange_rate}">
                                 </td>
                                 <td>
                                     <input class="form-control related"  type="text" name="room[id][child_actual_cost]" value="{$scenicInfo.child_actual_cost}" required>
                                 </td>
                                 <td>
                                     <input class="form-control related"  type="text" name="room[id][adult_actual_cost]" value="{$scenicInfo.adult_actual_cost}" required>
                                 </td>
                                 <td>
                                     <input class="form-control"  type="text" name="room[id][room_count]" value="{$scenicInfo.seat_num}" required>
                                 </td>
                             </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="hidden" name="is_review" value="-1">
                        <a class="btn btn-info" href="{:U('scenicProductById',array('id'=>I('supplier_id')))}">返回</a>
                        <button class="btn btn-warning" onclick="pass(-2)" >拒绝</button>
                        <button class="btn btn-primary" onclick="pass(1)" >通过</button>
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
</block>
<block name="js">
    <script>


        function pass(is_review) {
            $('input[name="is_review"]').val(is_review);
            $('form').submit();
        }


        //根据汇率自动转换价格
        var foreign=['child_foreign_cost','adult_foreign_cost'];
        var actual=['child_actual_cost','adult_actual_cost'];
        var _foreign,_actual;
        $('body').on('change','.related',function () {
            var name=$(this).attr('name');
            var val=$(this).val();
            var multiply_divide=1;//乘除
            if(name.indexOf('foreign')==-1){
                _foreign=actual;
                _actual=foreign;
                multiply_divide=0;
            }else{
                _foreign=foreign;
                _actual=actual;
                multiply_divide=1;
            }
            for(var i in _foreign){
                //汇率
                var exchangeName=name.replace(_foreign[i],'exchange_rate');
                var exchange_rate=  $('input[name=\''+exchangeName+'\']').val();
                if(!isNaN(exchange_rate)){
                    if(name.indexOf(_foreign[i])!=-1){
                        var changeName=name.replace(_foreign[i],_actual[i]);
                        var result=(val*exchange_rate).toFixed(2);
                        if(multiply_divide){
                            result=(val/exchange_rate).toFixed(2);
                        }
                        $('input[name=\''+changeName+'\']').val(result);
                    }
                }
            }
        });

        //改变汇率更换值
        $('body').on('change','.exchange_rate',function () {
            var reateName=$(this).attr('name');
            var val=$(this).val();
            for(var i in foreign){
                var name=reateName.replace('exchange_rate',foreign[i]);
                var tempVal=$('input[name=\''+name+'\']').val();
                if(tempVal){
                    var actualName=reateName.replace('exchange_rate',actual[i]);
                    var result=(tempVal/val).toFixed(2);
                    $('input[name=\''+actualName+'\']').val(result);
                }else{
                    var name=reateName.replace('exchange_rate',actual[i]);
                    var tempVal=$('input[name=\''+name+'\']').val();
                    if(tempVal){
                        var result=(tempVal*val).toFixed(2);
                        var foreignName=reateName.replace('exchange_rate',foreign[i]);
                        $('input[name=\''+foreignName+'\']').val(result);
                    }
                }
            }
        });

        //限制只能输入2位小数
        function num(obj)
        {
            //先把非数字的都替换掉，除了数字和.
            obj.value = obj.value.replace(/[^\d.]/g,"");
            //必须保证第一个为数字而不是.
            obj.value = obj.value.replace(/^\./g,"");
            //保证只有出现一个.而没有多个.
            obj.value = obj.value.replace(/\.{2,}/g,".");
            //保证.只出现一次，而不能出现两次以上
            obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
            obj.value=obj.value.substring(0,5);
        }

    </script>
</block>